﻿
void playWithScientists() {

    IDatabase db = Sqlite.OpenDatabase("scientists.db");

    // create a table 
    db.ExecuteSql("CREATE TABLE scientist(" +
            "id INTEGER PRIMARY KEY AUTOINCREMENT, " +
            "firstname TEXT, lastname TEXT)");

    // insert a number of values. Use a prepared statement with placeholders.
    IStatement insert_stmt = db.CreateStatement(
        "INSERT INTO scientist (firstname, lastname) values (?,?)");

    insert_stmt.BindParameters(new string[] { "Marie", "Curie" });
    insert_stmt.Step();
    insert_stmt.Reset();

    insert_stmt.BindParameters(new string[] { "Konrad", "Zuse" });
    insert_stmt.Step();
    insert_stmt.Reset();
    
    insert_stmt.BindParameters(new string[] { "?????????? ??????????", "???????????" });
    insert_stmt.Step();
    insert_stmt.Reset();

    insert_stmt.Close();

    // Now display the content of the table.
    IStatement select_stmt = db.CreateStatement("SELECT * FROM scientist");

    // First display the column names
    foreach (string column in select_stmt.ColumnNames) {
        Console.Write(column);
        Console.Write("\t");
    }
    Console.Write("\n");
    Console.WriteLine("------------------------------------");

    // Now the values
    while (select_stmt.Step()) {
        string[] values = select_stmt.ColumnValues();
        foreach (string value in values) {
            Console.Write(value);
            Console.Write("\t");
        }
        Console.Write("\n");
    }

    select_stmt.Close();

    // delete the table.
    db.ExecuteSql("DROP TABLE scientist");

    db.Close();

}

